import 'package:json_annotation/json_annotation.dart';

//定义生成的文件 flutter pub run build_runner build --delete-conflicting-outputs
part 'km_base_request.g.dart';

@JsonSerializable(explicitToJson: true)
class BaseKMRequest{

  String appId;
  String timestamp; //"2020-08-14 15:29:29"
  String randomNum; //9位随机数	Number	是	123456789
  String sign;

  BaseKMRequest(
      {
        required this.appId,
        required this.timestamp,
        required this.randomNum,
        required this.sign,
      }
      );

  //添加固定格式
  factory BaseKMRequest.fromJson(Map<String, dynamic> json) => _$BaseKMRequestFromJson(json);
  Map<String, dynamic> toJson() => _$BaseKMRequestToJson(this);


}

@JsonSerializable(explicitToJson: true)
class Request_km_xiaopiao extends BaseKMRequest{

  String templateId;
  String renderData;
  String requestId;
  int cut=1;

  Request_km_xiaopiao(
      {
        required this.templateId,
        required this.renderData,
        required this.requestId,
        this.cut=1,
        super.appId='',
        super.timestamp='',
        super.randomNum='',
        super.sign='',
      }
      );

  //添加固定格式
  factory Request_km_xiaopiao.fromJson(Map<String, dynamic> json) => _$Request_km_xiaopiaoFromJson(json);
  Map<String, dynamic> toJson() => _$Request_km_xiaopiaoToJson(this);

}

@JsonSerializable(explicitToJson: true)
class Request_km_biaoqian extends BaseKMRequest{

   String templateId;
   String renderData;//支持单标签渲染
   String requestId;
   int cut=1;
   int tsplType=1;
   int printTimes=1;//单标签渲染

   Request_km_biaoqian(
      {
        required this.templateId,
        required this.renderData,
        required this.requestId,
        this.cut=1,
        this.tsplType=1,
        this.printTimes=1,
        super.appId='',
        super.timestamp='',
        super.randomNum='',
        super.sign='',
      }
      );

  //添加固定格式
  factory Request_km_biaoqian.fromJson(Map<String, dynamic> json) => _$Request_km_biaoqianFromJson(json);
  Map<String, dynamic> toJson() => _$Request_km_biaoqianToJson(this);

}